from requests import get
from Config import Config


def get_ip():
    """
    获取ip
    """

    url = "http://dps.kdlapi.com/api/getdps"
    params = {
        "orderid": Config.orderid,
        "num": 1,
        "dedup": 1
    }
    resp = get(url, params=params)

    return resp.text


def get_blance():
    url = "https://dps.kdlapi.com/api/getipbalance"

    params = {
        "orderid": Config.orderid,
        "signature": Config.apikey,
        "sign_type": "simple"
    }

    resp = get(url, params=params)

    if resp.json()['data']['balance'] == 0:
        print("ip代理池余额不足")
        exit(0)


if __name__ == '__main__':
    # result = get_ip()
    get_blance()
